<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>应用明细表</title>
  <link rel="stylesheet" href="../../mobile_static/css/element.css">
  <link rel="stylesheet" href="../../mobile_static/css/base.css">
  <link rel="stylesheet" href="../../mobile_static/css/operationIndexAnalysis/allApplicationInformation.css">
  <script src="../../mobile_static/js/vue.js"></script>
  <script src="../../mobile_static/js/axios.js"></script>

</head>

<body>
  <div id="app">
    <div class="app-content">
      <!-- 导航栏 -->
      <div class="top-bar">
        <div>
          <el-button @click="backHome" type="primary" plain>返回</el-button>
        </div>
      </div>
      <!-- 表格 -->
      <div class="table-box">
        <!-- 表格标题 -->
        <div class="table-title flex between middle search-box-list">
          <h2>应用明细表</h2>
          <div class="search-box">
            <el-input prefix-icon="el-icon-search" style="width:200px;" v-model="searchValue" placeholder="按应用名搜索" @change="search">
            </el-input>
            <el-select v-model="value" filterable placeholder="请选择" @change="search" :disabled="jurisdiction">
              <el-option v-for="item in options" :key="item.g0departmentcode" :label="item.g0departmentname"
                :value="item.g0departmentcode">
              </el-option>
            </el-select>
            <el-button type="primary" @click="download">下载</el-button>
          </div>
        </div>
        <!-- 表格主体 -->
        <div class="table-main">
          <el-table :data="tableData" stripe max-height="600" v-loading="loading" border :header-cell-style="{background: 'linear-gradient(180deg, #FAFAFA 0%, #F1F1F1 100%)',fontSize:'16px',fontWeight:'bold',color:'#000000'}">
            <el-table-column prop="g0modulename" label="工作台应用名称" min-width="160">
            </el-table-column>
            <el-table-column prop="g0module_type_desc" label="工作台应用类型" min-width="150">
            </el-table-column>
            <el-table-column prop="g0app_type_desc" label="APP类型" min-width="150">
            </el-table-column>
            <el-table-column prop="g0enterprise_name" label="所属企业" min-width="200">
            </el-table-column>
            <el-table-column prop="g0createdtime" label="发布时间" min-width="200">
            </el-table-column>
          </el-table>
        </div>
        <!-- 分页 -->
        <div class="paging-box">
          <div class="block">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page"
              :page-sizes="[10, 20, 30, 40]" :page-size="size" layout="total, sizes, prev, pager, next, jumper"
              :total="length">
            </el-pagination>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

</html>
<script src="../../mobile_static/js/element.js"></script>
<script type="module">
  import { postThreeId, getThreeIdDownload } from '../../mobile_static/axios/axios.config.js'
  new Vue({
    el: "#app",
    data() {
      return {
        loading: false,

        timeValue: "", //日期value值

        options: [

        ],
        value: '', //选择器value值
        searchValue: "",
        tableData: [
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
          {
            applicationName: "公文审批",
            applicationType: '企业自建',
            AppType: 'iPhone',
            affiliatedCompanies: "总部",
            releaseTime: "2022-01-05 15:00:00",
          },
        ],
        size: 10,
        page: 1,
        length: '',
        jurisdiction: false
      }
    },
    created() {
      this.options = JSON.parse(sessionStorage.getItem('codeAll'))

      if (window.location.search) {
        this.value = window.location.search.slice(1).split("=")[1]
      }
      if (sessionStorage.getItem('jurisdiction') == 1) {
        this.jurisdiction = false
      } else {
        this.jurisdiction = true
      }
    },
    mounted() {
      this.ApplicationDetails()
    },
    methods: {
      search() {
        this.page = 1
        this.ApplicationDetails()
      },
      backHome() {
        window.history.back()
      },
      handleSizeChange(val) {
        this.size = val
        this.ApplicationDetails()
      },
      handleCurrentChange(val) {
        this.page = val
        this.ApplicationDetails()
      },
      //请求工作台新增明细
      ApplicationDetails() {
        this.loading = true

        postThreeId("zjsyqkmxb_gztxzmxyymxb_00", {
          pageSize: this.size,
          pageNum: this.page,
          g0moduleName: this.searchValue,
          g0enterpriseCode: this.value,
          g0levelflag: 1
        }).then(res => {
          this.loading = false

          res = JSON.parse(res.data.msg);
          // console.log(res, "请求工作台新增明细成功");
          if (res.total) {
            this.tableData = res.data
          } else {
            this.tableData = []
          }
          this.length = res.total
        })
      },
      //工作台新增明细下载
      download() {
        if (this.length > 50000) {
          this.$notify.error({
            title: '下载失败',
            message: "下载数据条数不能超过50000条",
          });
          return
        }
        this.loading = true
        getThreeIdDownload("zjsyqkmxb_gztxzmxyymxb_00Export", {
          pageSize: this.length,
          pageNum: 1,
          g0moduleName: this.searchValue,
          g0enterpriseCode: this.value
        }).then(res => {
          if (!res) {
            return
          }
          this.loading = false
          let url = window.URL.createObjectURL(res.data)
          let link = document.createElement("a")
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', '应用明细表.xlsx')
          document.body.appendChild(link)
          link.click()
        })
      },
    }
  })
</script>